package cn.tomas.queue.delayQueue.controller;

import cn.tomas.queue.delayQueue.sender.DelayMessageSender;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author Mr.Still
 * @version 1.0.0
 * @date 2021-11-11 17:36
 **/
@Api(tags = "延迟队列 生产者", description = "延迟队列 生产者")
@Slf4j
@RestController
@RequestMapping("/delayProduct")
public class DelayQueueProductController {

    @Autowired
    private DelayMessageSender delayMessageSender;

    @ApiOperation("延迟队列 消息生产接口")
    @GetMapping("/delaySendMsg")
    public void delaySendMsg(@ApiParam("消息") @RequestParam String msg, @ApiParam("延迟时间") @RequestParam int delayType) {
       log.info("当前时间：{},收到请求，msg:{},delayType:{}", new Date(), msg, delayType);
       delayMessageSender.sendMsg(msg,delayType);
    }

}
